{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  黄鹏辉\n",
    "+ 学号  0161918"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "脱贫调整0和False代表不改善，1和True代表改善\n",
      "第一户人\n",
      "该户不是贫困户\n",
      "第二户人\n",
      "该户不是贫困户\n",
      "第三户人\n",
      "该户为贫困户\n",
      "请对教育保障进行调整:1\n",
      "请对住房安全进行调整:1\n",
      "请对饮水安全进行调整:1\n",
      "请对豆蛋进行调整:1\n",
      "该户脱贫成功\n",
      "第四户人\n",
      "该户为贫困户\n",
      "请对住房安全进行调整:1\n",
      "请对饮水安全进行调整:1\n",
      "请对豆蛋进行调整:1\n",
      "该户脱贫成功\n"
     ]
    }
   ],
   "source": [
    "class pinkun():\n",
    "    def __init__(self,jiaoyu,zhufang,yinshui,shiwu):\n",
    "        self.jiaoyu=jiaoyu\n",
    "        self.zhufang=zhufang\n",
    "        self.yinshui=yinshui\n",
    "        self.shiwu=shiwu\n",
    "    def panduanpinkun(self):\n",
    "        self.sum=0\n",
    "        if self.jiaoyu==0:\n",
    "            self.sum+=1\n",
    "        if self.zhufang==0:\n",
    "            self.sum+=1\n",
    "        if self.yinshui==0:\n",
    "            self.sum+=1\n",
    "        if self.shiwu==0:\n",
    "            self.sum+=1\n",
    "        if self.sum>2:\n",
    "            print(\"该户为贫困户\")\n",
    "        else:\n",
    "            print(\"该户不是贫困户\")\n",
    "    def tuopin(self):\n",
    "        if self.sum>2:\n",
    "            if self.jiaoyu==0:\n",
    "                self.jiaoyu=input(\"请对教育保障进行调整:\")\n",
    "            if self.zhufang==0:\n",
    "                self.zhufang=input(\"请对住房安全进行调整:\")\n",
    "            if self.yinshui==0:\n",
    "                self.yinshui=input(\"请对饮水安全进行调整:\")\n",
    "            if self.shiwu==0:\n",
    "                self.shiwu=input(\"请对豆蛋进行调整:\")\n",
    "            n=0\n",
    "            if self.jiaoyu==0:\n",
    "                n+=1\n",
    "            if self.zhufang==0:\n",
    "                n+=1\n",
    "            if self.yinshui==0:\n",
    "                n+=1\n",
    "            if self.shiwu==0:\n",
    "                n+=1\n",
    "            if n>2:\n",
    "                print(\"该户脱贫失败\")\n",
    "            else:\n",
    "                print(\"该户脱贫成功\")\n",
    "print(\"脱贫调整0和False代表不改善，1和True代表改善\")                \n",
    "man1=pinkun(True,False,True,True)\n",
    "man2=pinkun(True,True,True,True)\n",
    "man3=pinkun(False,False,False,False)\n",
    "man4=pinkun(True,False,False,False)\n",
    "print(\"第一户人\")\n",
    "man1.panduanpinkun()\n",
    "man1.tuopin()\n",
    "print(\"第二户人\")\n",
    "man2.panduanpinkun()\n",
    "man2.tuopin()\n",
    "print(\"第三户人\")\n",
    "man3.panduanpinkun()\n",
    "man3.tuopin()\n",
    "print(\"第四户人\")\n",
    "man4.panduanpinkun()\n",
    "man4.tuopin()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第一个人\n",
      "请输入一个判断BMI的标准\n",
      "分数标准设为：90\n",
      "睡眠时间标准设为：6\n",
      "体重正常\n",
      "\n",
      "\n",
      "第二个人\n",
      "请输入一个判断BMI的标准\n",
      "分数标准设为：50\n",
      "睡眠时间标准设为：6\n",
      "BMI可能偏大\n",
      "\n",
      "\n",
      "第三个人\n",
      "请输入一个判断BMI的标准\n",
      "分数标准设为：90\n",
      "睡眠时间标准设为：5\n",
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class lei():\n",
    "    def __init__(self,xinming,fenshu,shuimian):\n",
    "        self.xinming=xinming\n",
    "        self.fenshu=fenshu\n",
    "        self.shuimian=shuimian\n",
    "    def pangshouyuce(self,fenshu,shuimian):\n",
    "        print(\"请输入一个判断BMI的标准\")\n",
    "        a=input(\"分数标准设为：\")#0-100分\n",
    "        b=input(\"睡眠时间标准设为：\")#单位小时\n",
    "        if self.fenshu > int(a) and self.shuimian < int(b) :\n",
    "            print(\"BMI可能偏大\")\n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "print(\"第一个人\")\n",
    "man_1=lei('zhangsan',100,7)\n",
    "man_1.pangshouyuce(fenshu=100,shuimian=7)\n",
    "print(\"\\n\")\n",
    "print(\"第二个人\")\n",
    "man_2=lei('lisi',80,5)\n",
    "man_2.pangshouyuce(fenshu=80,shuimian=5)\n",
    "print(\"\\n\")\n",
    "print(\"第三个人\")\n",
    "man_3=lei('wangmazi',85,6)\n",
    "man_3.pangshouyuce(fenshu=85,shuimian=6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第一个人\n",
      "请输入一个判断BMI的标准\n",
      "分数标准设为：90\n",
      "睡眠时间标准设为：6\n",
      "体重正常\n",
      "\n",
      "\n",
      "第二个人\n",
      "请输入一个判断BMI的标准\n",
      "分数标准设为：50\n",
      "睡眠时间标准设为：6\n",
      "BMI可能偏大\n",
      "趋于正常\n",
      "\n",
      "\n",
      "第三个人\n",
      "请输入一个判断BMI的标准\n",
      "分数标准设为：90\n",
      "睡眠时间标准设为：5\n",
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class paobushe(lei):\n",
    "    def __init__(self,xinming,fenshu,shuimian,time):\n",
    "        super().__init__(xinming,fenshu,shuimian)\n",
    "        self.time=time\n",
    "    def pangshouyuce(self,fenshu,shuimian,time):\n",
    "        print(\"请输入一个判断BMI的标准\")\n",
    "        a=input(\"分数标准设为：\")#0-100分\n",
    "        b=input(\"睡眠时间标准设为：\")#单位小时\n",
    "        if self.fenshu > int(a) and self.shuimian < int(b) :\n",
    "            print(\"BMI可能偏大\")\n",
    "            if self.time > 30 :\n",
    "                print(\"趋于正常\")\n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "print(\"第一个人\")\n",
    "man_1=paobushe('zhangsan',100,7,40)\n",
    "man_1.pangshouyuce(fenshu=100,shuimian=7,time=40)\n",
    "print(\"\\n\")\n",
    "print(\"第二个人\")\n",
    "man_2=paobushe('lisi',80,5,60)\n",
    "man_2.pangshouyuce(fenshu=80,shuimian=5,time=60)\n",
    "print(\"\\n\")\n",
    "print(\"第三个人\")\n",
    "man_3=paobushe('wangmazi',85,6,20)\n",
    "man_3.pangshouyuce(fenshu=85,shuimian=6,time=20)\n",
    "    "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
